package com.qianye.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qianye.entity.Customer;
import com.qianye.entity.Expressinfo;
import com.qianye.entity.Role;
import com.qianye.mapper.CustomerMapper;
import com.qianye.mapper.ExpressInfoMapper;
import com.qianye.mapper.RoleMapper;
import com.qianye.service.DaemonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class DaemonServiceImpl implements DaemonService {

    @Autowired
    private ExpressInfoMapper expressInfoMapper;

    @Autowired
    private CustomerMapper customerMapper;

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Expressinfo> findAllExpress(String express_owner_name, String express_sender_name, String express_owner_address, String yname, String yphone) {
        List<Expressinfo> expressinfoList = expressInfoMapper.findAllExpress(express_owner_name, express_sender_name, express_owner_address, yname, yphone);
        return expressinfoList;
    }

    @Override
    public List<Expressinfo> findAllExpressReject() {
        List<Expressinfo> expressinfoList = expressInfoMapper.findAllExpressReject();
        return expressinfoList;
    }

    @Override
    public List<Customer> findAllCustomer(String cusername, String cidcard, String cemail, String cphone, String caddress) {
        List<Customer> customerList = customerMapper.findAllCustomer(cusername, cidcard, cemail, cphone, caddress);
        return customerList;
    }

    @Override
    public List<Role> findAllRole() {
        List<Role> roleList = roleMapper.selectList(null);
        ArrayList<Role> roleArrayList = new ArrayList<>();
        roleArrayList.add(roleList.get(0));
        roleArrayList.add(roleList.get(1));
        roleArrayList.add(roleList.get(2));
        return roleArrayList;
    }

    @Override
    public Customer findAuth(Integer id) {
        Customer customer = customerMapper.findAuth(id);
        return customer;
    }
}
